<template>
<div class="line-main">
    <div class="page-header">
        <h1>路线规划</h1>
        <p>定制专属乡村旅游路线</p>
    </div>

    <!-- 右侧小众路线侧边栏 -->
    <div class="niche-sidebar" :class="{ 'collapsed': isNicheCollapsed }" v-if="nicheLines.length > 0">
        <div class="niche-toggle" @click="toggleNicheSidebar">
            <i :class="isNicheCollapsed ? 'el-icon-d-arrow-left' : 'el-icon-d-arrow-right'"></i>
            <span v-if="!isNicheCollapsed" class="toggle-text">收起</span>
        </div>
        <!-- 折叠状态下的标题 -->
        <div class="niche-collapsed-title" v-show="isNicheCollapsed">
            <span>小众路线推荐</span>
        </div>
        <div class="niche-content-wrapper" v-show="!isNicheCollapsed">
            <div class="niche-header">
                <h3>小众路线推荐</h3>
            </div>
            <div class="niche-list">
                <div class="niche-item" v-for="(line, index) in nicheLines" :key="line.lineID || index" @click="showDetail(line, index)">
                    <div class="niche-image">
                        <img :src="line.linePicture" :alt="`${line.lineStart}至${line.lineEnd}`" />
                    </div>
                    <div class="niche-info">
                        <h4>{{ line.lineStart }} → {{ line.lineEnd }}</h4>
                        <p><i class="el-icon-s-promotion"></i> {{ line.lineTimes }}</p>
                        <p><i class="el-icon-s-ticket"></i> {{ line.linePrice }}元/人</p>
                        <p><i class="el-icon-location"></i> {{ line.lineType }}</p>
                        <div class="niche-rating">
                            <el-rate v-model="line.lineStar" disabled show-score text-color="#ff9900" :max="5" :allow-half="true"></el-rate>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="cards-container" :class="{ 'with-sidebar': nicheLines.length > 0 && !isNicheCollapsed, 'with-sidebar-collapsed': nicheLines.length > 0 && isNicheCollapsed }">
        <div class="line-card" v-for="(line, index) in tableData" :key="index" @click="showDetail(line, index)">
            <div class="card-image">
                <img :src="line.linePicture" :alt="line.lineName" />
            </div>
            <div class="card-content">
                <h3 class="card-title">{{ line.lineStart }} → {{ line.lineEnd }}</h3>
                <div class="card-info">
                    <p class="info-item">
                        <i class="el-icon-s-promotion"></i>
                        {{ line.lineTimes }}
                    </p>
                    <p class="info-item">
                        <i class="el-icon-s-ticket"></i>
                        {{ line.linePrice }}
                    </p>
                    <div class="rating">
                        <el-rate v-model="line.lineStar" disabled show-score text-color="#ff9900" :max="5"></el-rate>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 详情对话框 -->
    <el-dialog
        title="线路详情"
        :visible.sync="detailVisible"
        width="800px"
        :before-close="handleClose">
        <div class="detail-dialog" v-if="selectedLine">
            <div class="detail-image">
                <img :src="selectedLine.linePicture" :alt="selectedLine.lineName" />
            </div>
            <div class="detail-content">
                <h2>{{ selectedLine.lineStart }} → {{ selectedLine.lineEnd }}</h2>
                <div class="detail-info">
                    <p><i class="el-icon-s-promotion"></i> 线路时长：{{ selectedLine.lineTimes }}</p>
                    <p><i class="el-icon-s-ticket"></i> 线路价格：{{ selectedLine.linePrice }}</p>
                    <p><i class="el-icon-location"></i> 线路类型：{{ selectedLine.lineType }}</p>
                    <p><i class="el-icon-guide"></i> 起点：{{ selectedLine.lineStart }}</p>
                    <p><i class="el-icon-flag"></i> 终点：{{ selectedLine.lineEnd }}</p>
                    <p><i class="el-icon-phone"></i> 联系电话：{{ selectedLine.linePhone }}</p>
                    <p><i class="el-icon-star-on"></i> 推荐星级：<el-rate v-model="selectedLine.lineStar" disabled show-score text-color="#ff9900" :max="5"></el-rate></p>
                    <p><i class="el-icon-document"></i> 线路介绍：{{ selectedLine.lineDesc }}</p>
                </div>
                <div class="detail-actions">
                    <el-button type="primary" size="large" @click="handleBook">立即报名</el-button>
                </div>
            </div>
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button @click="detailVisible = false">关 闭</el-button>
        </span>
    </el-dialog>

    <!-- 预订对话框 -->
    <el-dialog
        title="报名线路"
        :visible.sync="dialogVisible"
        width="500px"
        :before-close="handleClose">
        <div class="booking-dialog">
            <el-table :data="bookingInfo" border style="width: 100%; margin-bottom: 20px;">
                <el-table-column prop="name" label="项目" width="120"></el-table-column>
                <el-table-column prop="value" label="内容"></el-table-column>
            </el-table>

            <el-form :model="bookForm" label-width="100px">
                <el-form-item label="报名数量" required>
                    <el-input-number v-model="bookForm.quantity" :min="1" style="width: 100%;"></el-input-number>
                </el-form-item>
                <el-form-item label="报名时间" required>
                    <el-date-picker
                        v-model="bookForm.bookTime"
                        type="datetime"
                        placeholder="选择日期时间"
                        :picker-options="{
                            disabledDate(time) {
                                return time.getTime() < Date.now() - 86400000;
                            }
                        }"
                        style="width: 100%;">
                    </el-date-picker>
                </el-form-item>
            </el-form>
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="confirmBooking">确 定</el-button>
        </span>
    </el-dialog>
</div>
</template>

<script>
const axios = require('axios')
const qs = require('qs')
const ele = require('element-ui')

// 动态加载百度地图API
// function loadBaiduMapScript() {
//     return new Promise((resolve, reject) => {
//         console.log('开始加载百度地图API');
//
//         if (window.BMap) {
//             console.log('百度地图API已加载');
//             resolve(window.BMap);
//             return;
//         }
//
//         // 创建全局回调函数
//         window.initBMap = function() {
//             console.log('百度地图API初始化回调触发');
//             if (window.BMap) {
//                 console.log('BMap对象已创建');
//                 resolve(window.BMap);
//             } else {
//                 console.error('BMap对象未创建');
//                 reject(new Error('BMap对象未创建'));
//             }
//         };
//
//         const script = document.createElement('script');
//         script.type = 'text/javascript';
//         script.src = 'https://api.map.baidu.com/api?v=3.0&ak=mr5DYlRg2yZGvSU8ScQI2RZWt5RYFlcsAK&callback=initBMap';
//
//         script.onload = function() {
//             console.log('百度地图API脚本已加载');
//             // 如果回调没有触发，5秒后检查
//             setTimeout(() => {
//                 if (window.BMap) {
//                     console.log('BMap对象已创建（延迟检查）');
//                     resolve(window.BMap);
//                 }
//             }, 5000);
//         };
//
//         script.onerror = function(e) {
//             console.error('百度地图API脚本加载失败', e);
//             reject(e);
//         };
//
//         document.head.appendChild(script);
//         console.log('百度地图API脚本已添加到文档');
//     });
// }

export default {
    name: 'line_page',
    data() {
        return {
            lineID: '',
            lineName: '',
            lineTimes: '',
            lineStart: '',
            lineEnd: '',
            linePrice: '',
            lineType: '',
            lineDesc: '',
            lineAuthor: '',
            linePhone: '',
            lineStatus: '',
            lineStar: 0,
            linePicture: '',
            tableData: [],
            // 详情相关数据
            detailVisible: false,
            selectedLine: null,
            // 小众路线推荐
            nicheLines: [],
            isNicheCollapsed: false,
            // 预订相关数据
            dialogVisible: false,
            bookForm: {
                quantity: 1,
                bookTime: ''
            },
            bookingInfo: []
        }
    },
    methods: {
        detail(index) {
            this.lineID = this.tableData[index].lineID
            this.lineName = this.tableData[index].lineName
            this.lineTimes = this.tableData[index].lineTimes
            this.lineStart = this.tableData[index].lineStart
            this.lineEnd = this.tableData[index].lineEnd
            this.linePrice = this.tableData[index].linePrice
            this.lineType = this.tableData[index].lineType
            this.linePicture = this.tableData[index].linePicture
            this.lineAuthor = this.tableData[index].lineAuthor
            this.lineDesc = this.tableData[index].lineDesc
            this.linePhone = this.tableData[index].linePhone
            this.lineStatus = this.tableData[index].lineStatus
            this.lineStar = parseFloat(this.tableData[index].lineStar)

            // 初始化地图
            // this.$nextTick(() => {
            //     this.initMap();
            // });
        },
        showDetail(line, index) {
            this.selectedLine = line;
            this.detailVisible = true;
        },
		handleBook() {
            const currentUser = localStorage.getItem("userName");
			if (currentUser === "" || currentUser == null) {
				this.$message.warning('请先登录');
				this.$router.push('/login');
				return;
			}

            // 设置当前选中的线路信息
            if (this.selectedLine) {
                this.lineID = this.selectedLine.lineID;
                this.lineName = this.selectedLine.lineName;
                this.linePrice = this.selectedLine.linePrice;
                this.lineType = this.selectedLine.lineType;
                this.lineTimes = this.selectedLine.lineTimes;
                this.lineStart = this.selectedLine.lineStart;
                this.lineEnd = this.selectedLine.lineEnd;
                this.linePhone = this.selectedLine.linePhone;
                this.lineStar = this.selectedLine.lineStar;
            }

            // 准备预订信息
            this.bookingInfo = [
                {
                    name: '线路名称',
                    value: this.lineName
                },
                {
                    name: '线路价格',
                    value: this.linePrice
                },
                {
                    name: '线路类型',
                    value: this.lineType
                },
                {
                    name: '线路时长',
                    value: this.lineTimes
                },
                {
                    name: '起点',
                    value: this.lineStart
                },
                {
                    name: '终点',
                    value: this.lineEnd
                },
                {
                    name: '推荐星级',
                    value: this.lineStar,
                    render: (h, params) => {
                        return h('el-rate', {
                            props: {
                                value: params.row.value,
                                disabled: true,
                                'show-score': false,
                                'text-color': '#ff9900'
                            }
                        })
                    }
                }
            ];

            // 重置表单
            this.bookForm = {
                quantity: 1,
                bookTime: new Date()
            };

            // 显示对话框
            this.dialogVisible = true;
        },

        // 确认预订
        confirmBooking() {
            // 表单验证
            if (!this.bookForm.quantity || !this.bookForm.bookTime) {
                this.$message.warning('请填写完整报名信息');
                return;
            }

            this.$confirm('确认报名吗？', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                let _this = this;
                axios({
                    method: 'post',
                    url: 'http://localhost:8080/buyLine',
                    headers: {
                        'Content-type': 'application/x-www-form-urlencoded'
                    },
                    params: {
                        lineID: this.lineID,
                        num: this.bookForm.quantity,
                        startDate: this.bookForm.bookTime,
                        userName: localStorage.getItem("userName")
                    }
                }).then(function(response) {
                    console.log(response.data)
					if(response.data.status === "success"){
						_this.$message.success(response.data.message);
                    	_this.dialogVisible = false;
					}else{
						_this.$message.error(response.data.message);
                    	console.log(error);
					}
                }).catch(function(error) {
                    _this.$message.error('报名失败');
                    console.log(error);
                });
            }).catch(() => {
                // 取消报名，不做处理
            });
        },

        // 关闭对话框
        handleClose(done) {
            this.detailVisible = false;
            this.dialogVisible = false;
            this.selectedLine = null;
            if (done) done();
        },
        // 切换小众路线侧边栏展开/收起
        toggleNicheSidebar() {
            this.isNicheCollapsed = !this.isNicheCollapsed;
        },
        fetchNicheLines() {
            const _this = this;
            axios({
                method: 'get',
                url: 'http://localhost:8080/getLastLines',
                headers: {
                    'Content-type': 'application/x-www-form-urlencoded'
                }
            }).then(function(response) {
                const list = response.data && (response.data.dataList || response.data);
                if (Array.isArray(list) && list.length > 0) {
                    _this.nicheLines = list.map(item => _this.adaptLineData(item));
                    // 如果有数据，自动展开侧边栏
                    _this.isNicheCollapsed = false;
                } else {
                    _this.nicheLines = [];
                }
            }).catch(function(error) {
                console.log('获取小众路线失败', error);
                _this.nicheLines = [];
            });
        },
        adaptLineData(line) {
            if (!line) {
                return {};
            }
            return {
                ...line,
                lineStar: line.lineStar ? parseFloat(line.lineStar) : 0
            };
        },
        initMap() {
            console.log('初始化地图，起点:', this.lineStart, '终点:', this.lineEnd);

            if (!this.lineStart || !this.lineEnd) {
                console.error('起点或终点未设置');
                return;
            }

            if (!window.BMap) {
                console.error('百度地图API未加载');
                // 尝试重新加载API
                loadBaiduMapScript().then(() => {
                    console.log('百度地图API重新加载成功，重试初始化地图');
                    this.$nextTick(() => {
                        this.initMapAfterAPILoaded();
                    });
                }).catch(error => {
                    console.error('百度地图API重新加载失败:', error);
                });
                return;
            }

            this.initMapAfterAPILoaded();
        },

        // initMapAfterAPILoaded() {
        //     try {
        //         console.log('API已加载，开始初始化地图');
		//
        //         // 创建地图实例
        //         const map = new window.BMap.Map("allmap");
		//
        //         // 清除覆盖物
        //         map.clearOverlays();
		//
        //         // 设置地图中心点和缩放级别（使用中国的中心点）
        //         map.centerAndZoom(new window.BMap.Point(116.404, 39.915), 5);
		//
        //         // 启用滚轮缩放
        //         map.enableScrollWheelZoom(true);
		//
        //         // 添加控件
        //         map.addControl(new window.BMap.NavigationControl());
        //         map.addControl(new window.BMap.ScaleControl());
        //         map.addControl(new window.BMap.OverviewMapControl());
		//
        //         console.log('地图初始化完成，开始规划路线');
		//
        //         // 使用驾车路线规划
        //         const driving = new window.BMap.DrivingRoute(map, {
        //             renderOptions: {
        //                 map: map,
        //                 autoViewport: true
        //             },
        //             policy: window.BMAP_DRIVING_POLICY_LEAST_DISTANCE // 使用最短距离策略
        //         });
		//
        //         // 添加路线规划结果事件监听
        //         driving.setSearchCompleteCallback((results) => {
        //             if (driving.getStatus() == window.BMAP_STATUS_SUCCESS) {
        //                 console.log('路线规划成功');
        //             } else {
        //                 console.error('路线规划失败，状态码:', driving.getStatus());
        //             }
        //         });
		//
        //         // 搜索路线
        //         console.log('开始搜索路线，起点:', this.lineStart, '终点:', this.lineEnd);
        //         driving.search(this.lineStart, this.lineEnd);
		//
        //     } catch (error) {
        //         console.error('地图初始化或路线规划出错:', error);
        //     }
        // }
    },
    created() {
        let _this = this
        this.userName = window.localStorage.getItem('userName')

        this.fetchNicheLines()

        axios({
            method: 'get',
            url: 'http://localhost:8080/getLineList',
            headers: {
                'Content-type': 'application/x-www-form-urlencoded'
            }
        }).then(function (response) {
            _this.tableData = response.data.dataList
            console.log(_this.tableData)

            // 如果有数据，默认显示第一条线路的详情
            // if (_this.tableData && _this.tableData.length > 0) {
            //     _this.detail(0);
            // }
        }).catch(function (error) {
            console.log(error)
        })
    },

    // mounted() {
    //     console.log('组件挂载完成，开始加载百度地图API');
    //     // 在组件挂载后加载百度地图API
    //     loadBaiduMapScript().then(() => {
    //         console.log('百度地图API加载成功');
    //         // 如果已经有线路数据，初始化地图
    //         if (this.lineStart && this.lineEnd) {
    //             this.$nextTick(() => {
    //                 this.initMap();
    //             });
    //         }
    //     }).catch(error => {
    //         console.error('百度地图API加载失败:', error);
    //     });
    // },

    // watch: {
    //     // 监听起点和终点的变化，当它们变化时重新初始化地图
    //     lineStart() {
    //         if (this.lineStart && this.lineEnd && window.BMap) {
    //             this.$nextTick(() => {
    //                 this.initMap();
    //             });
    //         }
    //     },
    //     lineEnd() {
    //         if (this.lineStart && this.lineEnd && window.BMap) {
    //             this.$nextTick(() => {
    //                 this.initMap();
    //             });
    //         }
    //     }
    // }
};
</script>

<style scoped>
.line-main {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px 20px;
    position: relative;
}

/* 右侧小众路线侧边栏样式 */
.niche-sidebar {
    position: fixed;
    right: 0;
    top: 60px; /* 导航栏高度，避免遮挡导航栏 */
    height: calc(100vh - 60px); /* 总高度减去导航栏高度 */
    width: 380px;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 9; /* 小于导航栏的z-index(10)，确保不遮挡导航栏 */
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.niche-sidebar.collapsed {
    transform: translateX(calc(100% - 50px));
}

.niche-toggle {
    position: absolute;
    left: -40px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 80px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px 0 0 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    z-index: 10; /* 确保按钮在标题上方，始终可点击 */
}

.niche-toggle:hover {
    background: white;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.15);
}

.niche-toggle i {
    font-size: 20px;
    color: #667eea;
    margin-bottom: 4px;
}

.niche-toggle .toggle-text {
    font-size: 12px;
    color: #667eea;
    writing-mode: vertical-lr;
    text-orientation: upright;
    white-space: nowrap;
}

.niche-sidebar.collapsed .niche-toggle {
    left: -50px;
    width: 50px;
    height: 60px;
}

.niche-sidebar.collapsed .niche-toggle .toggle-text {
    display: none;
}

/* 折叠状态下的标题 */
.niche-collapsed-title {
    position: absolute;
    top: 0;
    left: 0;
    width: 50px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 1px;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    z-index: 1;
    padding: 10px 0;
}

.niche-collapsed-title span {
    writing-mode: vertical-lr;
    text-orientation: mixed;
    line-height: 1.6;
}

.niche-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.niche-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.niche-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.niche-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.niche-item {
    display: flex;
    flex-direction: column;
    background: #f7f9fc;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.3s ease;
}

.niche-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    background: #f0f4f8;
}

.niche-image {
    width: 100%;
    height: 140px;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 10px;
}

.niche-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.niche-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.niche-info h4 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.niche-info p {
    margin: 0;
    font-size: 0.85rem;
    color: #555;
    display: flex;
    align-items: center;
}

.niche-info i {
    color: #42b983;
    margin-right: 6px;
    width: 16px;
}

.niche-rating {
    margin-top: 8px;
}

.page-header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.page-header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.page-header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    max-width: 1400px;
    margin: 0 auto;
    transition: margin-right 0.3s ease;
}

.cards-container.with-sidebar {
    margin-right: 380px;
    padding-right: 20px;
}

.cards-container.with-sidebar-collapsed {
    margin-right: 50px;
    padding-right: 0;
}

.line-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    cursor: pointer;
}

.line-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.card-image {
    position: relative;
    height: 250px;
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.line-card:hover .card-image img {
    transform: scale(1.05);
}

.card-content {
    padding: 15px;
    height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-item {
    display: flex;
    align-items: center;
    color: #666;
    font-size: 0.85rem;
    margin: 0;
}

.info-item i {
    color: #42b983;
    margin-right: 6px;
    width: 14px;
}

.rating {
    margin-top: 5px;
}

/* 详情对话框样式 */
.detail-dialog {
    display: flex;
    gap: 20px;
}

.detail-image {
    flex: 1;
}

.detail-image img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    border-radius: 8px;
}

.detail-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.detail-content h2 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.8rem;
    font-weight: 600;
}

.detail-info p {
    margin: 12px 0;
    color: #666;
    line-height: 1.6;
    display: flex;
    align-items: flex-start;
}

.detail-info i {
    color: #42b983;
    margin-right: 8px;
    width: 16px;
    margin-top: 2px;
}

.detail-actions {
    margin-top: 20px;
    text-align: center;
}

/* 地图容器样式 */
#allmap {
    width: 100%;
    height: 400px;
    margin-top: 20px;
    border: 1px solid #ccc;
    border-radius: 8px;
    overflow: hidden;
}

/* 预订对话框样式 */
.booking-dialog .el-input-number {
    width: 100%;
}

.booking-dialog .el-form-item {
    margin-bottom: 20px;
}

.custom-dialog .el-dialog__body {
    padding: 20px 30px;
}

.el-dialog {
    border-radius: 8px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .cards-container {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
    }
    
    .cards-container.with-sidebar {
        margin-right: 0;
        padding-right: 0;
    }
    
    .niche-sidebar {
        width: 320px;
    }
    
    .niche-sidebar.collapsed {
        transform: translateX(calc(100% - 45px));
    }
    
    .niche-sidebar.collapsed .niche-toggle {
        left: -45px;
        width: 45px;
    }
    
    .page-header h1 {
        font-size: 2rem;
    }
    
    .page-header p {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .cards-container {
        grid-template-columns: 1fr;
    }
    
    .line-main {
        padding: 20px 10px;
    }
    
    .niche-sidebar {
        width: 100%;
    }
    
    .niche-sidebar.collapsed {
        transform: translateX(calc(100% - 40px));
    }
    
    .niche-sidebar.collapsed .niche-toggle {
        left: -40px;
        width: 40px;
    }
}
</style>
